package com.cmcc.shared.utils

import android.content.Context
import android.location.LocationManager
import android.content.Context.LOCATION_SERVICE


/**
 * 判断 GPS 开关【位置信息】是否开启
 * 通用方法（非Googelmap也可以用）
 * @param context
 * @return true 表示开启
 */
fun isOPenGps(context: Context): Boolean {
    val locationManager = context.getSystemService(LOCATION_SERVICE) as LocationManager
    //GPS卫星定位
    val gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
    //WLAN或移动网络(4G/3G/2G)
    val network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
    return gps || network
}

